package com.qn.analyze.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qn.analyze.entity.AccessRecords;
import com.qn.analyze.entity.IpAddressRecord;
import com.qn.analyze.entity.UserAgentRecord;
import com.qn.analyze.entity.UserLanguageRecord;
import com.qn.analyze.mapper.AccessRecordsMapper;
import com.qn.analyze.vo.AccessRecordsQueryVo;
import com.qn.analyze.vo.IpAddressRecordQueryVo;
import com.qn.analyze.vo.UserAgentRecordQueryVo;
import com.qn.analyze.vo.UserLanguageRecordQueryVo;
import com.qn.common.base.BaseServiceImpl;
import com.qn.common.base.model.BasicFetchPage;
import com.qn.common.base.model.RequestPage;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * qingniu-cloud user source analysis
 *
 * @Author: TXG
 * @Date: 2024/6/11
 * @Version V0.0.2
 */
@DubboService(version = "1.0.0")
public class AccessRecordsServiceImpl
        extends BaseServiceImpl<AccessRecords>
        implements AccessRecordsService {
    @Autowired
    AccessRecordsMapper baseMapper;
    @Override
    public BasicFetchPage<AccessRecords> getAccessPageList(RequestPage<AccessRecordsQueryVo> rpage) {
        IPage<AccessRecordsQueryVo> page = new Page<>(rpage.getPage(), rpage.getPageSize());
        IPage<AccessRecords> pageList = baseMapper.getAccessPageList(page, rpage.getWhere());
        return new BasicFetchPage(pageList.getTotal(), pageList.getRecords());
    }

    @Override
    public BasicFetchPage<IpAddressRecord> getIpAddressrPageList(RequestPage<IpAddressRecordQueryVo> rpage) {
        IPage<IpAddressRecordQueryVo> page = new Page<>(rpage.getPage(), rpage.getPageSize());
        IPage<IpAddressRecord> pageList = baseMapper.getIpAddressrPageList(page, rpage.getWhere());
        return new BasicFetchPage(pageList.getTotal(), pageList.getRecords());
    }

    @Override
    public BasicFetchPage<UserAgentRecord> getUserAgentPageList(RequestPage<UserAgentRecordQueryVo> rpage) {
        IPage<UserAgentRecordQueryVo> page = new Page<>(rpage.getPage(), rpage.getPageSize());
        IPage<UserAgentRecord> pageList = baseMapper.getUserAgentPageList(page, rpage.getWhere());
        return new BasicFetchPage(pageList.getTotal(), pageList.getRecords());
    }

    @Override
    public BasicFetchPage<UserLanguageRecord> getLanguagePageList(RequestPage<UserLanguageRecordQueryVo> rpage) {
        IPage<UserLanguageRecordQueryVo> page = new Page<>(rpage.getPage(), rpage.getPageSize());
        IPage<UserLanguageRecord> pageList = baseMapper.getLanguagePageList(page, rpage.getWhere());
        return new BasicFetchPage(pageList.getTotal(), pageList.getRecords());
    }
}
